package com.ruoyi.web.entity;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;

/**
 * 统一返回参数类型
 */
@Data
@AllArgsConstructor
public class Result implements Serializable {

    public static final Result OK = new Result(200, "操作成功", null);

    public static final Result FAIL = new Result(400, "操作失败", null);

    public static final Result SYSTEM_ERROR = new Result(500, "系统错误", null);

    public static final Result SYS_PARAM_ERROR = new Result(400, "param error",null);

    public static  final Result PARAM_VERIFY_ERROR = new Result(400,"校验失败", null);

    public static final Result LOGIN_ERROR = new Result(400,"登录信息错误，请重新登陆",null);

    public static final Result OPENID_ERROR = new Result(400,"授权信息错误，请尝试重新授权",null);

    public static final  Result NOT_AGENT = new Result(400,"未查询到代理信息",null);

    public static final  Result NOT_SITE = new Result(400,"未查询到商户信息",null);

    public static final  Result NOT_PRODUCT = new Result(410,"未查询到设备信息",null);

    public static final  Result SYS_BUSY = new Result(500, "系统繁忙，请稍后再试",null);

    Integer code;
    String msg;
    Object data;

    /**
     * 操作成功
     */
    public static final Integer SUCCESS_CODE = 200;

    /**
     * 操作失败
     */
    public static final Integer FAIL_CODE = 400;

    /**
     * 系统错误
     */
    public static final Integer SYSTEM_ERROR_CODE = 500;


    public static Result success(String msg){return new Result(SUCCESS_CODE,msg,null);}

    public static Result success(Object data) {return new Result(SUCCESS_CODE,"操作成功",data);}

    public static Result success(String msg, Object data) {return new Result(SUCCESS_CODE,msg,data);}


    public static Result fail(String msg){return new Result(FAIL_CODE,msg,null);}

    public static Result fail(Object data) {return new Result(FAIL_CODE,"操作成功",data);}

    public static Result fail(String msg, Object data) {return new Result(FAIL_CODE,msg,data);}

    public static Result error(String msg){return new Result(SYSTEM_ERROR_CODE, msg,null);}


}
